package lzm.config;

import com.alibaba.druid.pool.DruidDataSource;
import lzm.condition.LinuxCondition;
import lzm.condition.WindowsCondition;
import lzm.entity.importSel.LinuxCla;
import lzm.entity.importSel.WindowCla;
import lzm.register.BeanRegister02;
import lzm.selector.ColorSelector;
import lzm.spring.config.EnableRpcPost;
import org.springframework.context.annotation.*;

@Configuration
@ComponentScan(basePackages = {"lzm"})
@PropertySource(value = {"classpath:jdbc.properties"})
@EnableRpcPost("lzm.spring.rpc")
@Import({ColorSelector.class})
@ImportResource(locations = {"classpath*:bean01.xml"})
@EnableAspectJAutoProxy
public class WebXml {

    /**
     * 配置的方式
     * @return
     */
    @Bean(name = "datSource")
    public DruidDataSource getDruidDataSource() {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
        druidDataSource.setUrl("jdbc:mysql://localhost:3306/study");
        druidDataSource.setUsername("root");
        druidDataSource.setPassword("123456");
        return druidDataSource;
    }


    @Bean(value = "windowCla02")
    public WindowCla getWindowCla02() {
        return new WindowCla();
    }

    @Conditional(WindowsCondition.class)
    @Bean(value = "windowCla01")
    public WindowCla getWindowCla() {
        return new WindowCla();
    }


    @Conditional(LinuxCondition.class)
    @Bean(value = "linuxCla01")
    public LinuxCla getLinuxCla() {
        return new LinuxCla();
    }




}
